cssnode: Clear cache if reusing style
authorBenjamin Otte <otte@redhat.com>
Tue, 15 Dec 2015 00:07:03 +0000 (01:07 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 15 Dec 2015 00:15:51 +0000 (01:15 +0100)
When we reuse styles that didn't change across changes to the source
CSS, make sure we clear the caches. Otherwise child nodes will pick up
styles from the old source CSS.

gtk/gtkcssnode.c

index a1bbe77d3668abae733eaf46d7df46875bcc719c..0772369fae4913e093dd95e4a4b4309fd7585bbc 100644 (file)
@@ -1034,6 +1034,12 @@ gtk_css_node_ensure_style (GtkCssNode *cssnode,
 
       style_changed = gtk_css_node_set_style (cssnode, new_style);
       g_object_unref (new_style);
+
+      if (!style_changed && (cssnode->pending_changes & GTK_CSS_CHANGE_SOURCE))
+        {
+          /* clear the global cache if we reuse the same style after the CSS changed */
+          g_object_set_qdata (G_OBJECT (cssnode->style), quark_global_cache, NULL);
+        }
     }
   else
     {